<?php


namespace app\admin\validate;


use think\Validate;

/**
 * Class Structure
 * @package app\admin\validate
 * @author Mr.Liu Wuchen
 * @create 2021-07-27 15:49
 */
class Structure extends Validate
{

    /**
     * 验证规则
     * @var string[]
     */
    protected $rule = [
        'id'     => 'require|number|gt:0',
        'pid'    => 'require|number|gt:0',
        'name'   => 'require|max:6',
        'sort'   => 'require|number|gt:0|lt:10000',
        'remark' => 'max:150',
    ];

    /**
     * 错误信息
     * @var string[]
     */
    protected $message = [
        'id.require'   => '参数错误',
        'id.number'    => '参数错误',
        'id.gt'        => '参数错误',
        'pid.require'  => '请选择上级部门',
        'pid.number'   => '请选择上级部门',
        'pid.gt'       => '请选择上级部门',
        'name.require' => '请填写部门名称',
        'name.unique'  => '部门名称已经存在',
        'name.max'     => '部门名称最多6个字符',
        'sort.require' => '请填写排序',
        'sort.number'  => '排序范围1~9999',
        'sort.gt'      => '排序范围1~9999',
        'sort.lt'      => '排序范围1~9999',
        'remark.max'   => '描述最多150个字符',
    ];


    /**
     * 验证场景
     * @var string[]
     */
    protected $scene = [
        'create' => ['pid', 'name', 'sort', 'remark'],
        'update' => ['id', 'name', 'sort', 'remark'],
    ];

}